package com.memorypalace.biz;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.memorypalace.deck.mapper.DeckMapper;
import com.memorypalace.deck.mapper.NoteMapper;
import com.memorypalace.deck.mapper.NoteTypeMapper;
import com.memorypalace.deck.vo.NoteAndCardStyleId;
import com.memorypalace.knowledge.mapper.NoteConnectMapper;
import com.memorypalace.knowledge.pojo.NoteConnect;
import com.memorypalace.pojo.CardStyle;
import com.memorypalace.pojo.Deck;
import com.memorypalace.pojo.Note;
import com.memorypalace.pojo.NoteType;

@Service("noteConnectBiz")
public class NoteConnectBiz implements INoteConnectBiz {

	@Autowired
	private NoteConnectMapper noteConnectMapper;
	@Autowired
	private NoteMapper noteMapper;
	
	@Override
	public List<Note> getNotesByFatherKnowledgeId(String KnowledgeId) {
		List<NoteConnect> noteConnectList = noteConnectMapper.getNoteConnectByFatherKnowledgeId(KnowledgeId);
		List<Note> notes = new ArrayList<Note>();
		
		for (NoteConnect noteConnect : noteConnectList) {
			String noteId = noteConnect.getNoteId();
			Note note = noteMapper.getNoteWithDeckAndNoteTypeById(noteId);
			notes.add(note);
		}
		return notes;
	}

	@Override
	public Integer addNoteConnect(NoteConnect noteConnect) {
		
		return noteConnectMapper.addNoteConnect(noteConnect);
	}

	@Override
	public Integer deleteNoteConnectsByFatherKnowledgeId(String knowledgeId) {
		return noteConnectMapper.deleteNoteConnectsByFatherKnowledgeId(knowledgeId);
	}
	

}
